/**
 * Copyright (c) 2013 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.android.chargemybattery.actions;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class PowerSaveActionContainer {
    private final static PowerSaveActionContainer INSTANCE = new PowerSaveActionContainer();

    private final List<iPowerSaveAction>          actions  = new ArrayList<iPowerSaveAction>();

    public void addAction( iPowerSaveAction anAction ) {
        actions.add( anAction );
    }

    public void execute() {
        Log.d( PowerSaveActionContainer.class.getName(), "Executing power save cycle" );
        for ( iPowerSaveAction theAction : actions ) {
            if ( theAction.isEnabled() && !theAction.isComplete() ) {
                theAction.execute();
            }
        }
    }

    public void undo() {
        for ( iPowerSaveAction theAction : actions ) {
            theAction.undo();
        }
    }

    public static PowerSaveActionContainer getInstance() {
        return INSTANCE;
    }
}
